package com.itlong.cloud.wechat.resource;

import com.itlong.cloud.iottp.IWeChatMessageServiceClient;
import com.itlong.cloud.wechat.service.IWeChatMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <desc>
 *      微信模板消息暴露接口实现类
 * </desc>
 *
 * @createDate 2019/04/26
 */
@RestController
public class WeChatMessageServiceResource implements IWeChatMessageServiceClient {

    @Autowired
    private IWeChatMessageService iWeChatMessageService;

    /**
     * <desc>
     *      处理微信发来的请求返回推送xml
     * </desc>
     *
     * @param request
     * @return
     *@createDate 2019/05/17
     */
    @Override
    @RequestMapping(path = "/iotTp/message/processRequestForNews",method = RequestMethod.POST)
    public String processRequestForNews(@RequestBody Map<String, String> request){
        return iWeChatMessageService.processRequestForNews(request);
    }

    /**
     * <desc>
     *      定时任务更新微信公众号与小程序之间的关联关系
     * </desc>
     *
     * @throws Exception
     * @author Jiaqi.X
     * @createDate 2019/05/21
     */
    @Override
    @RequestMapping(path = "/iotTp/message/bindOfficeOpenIdAndMiniProgramOpenId",method = RequestMethod.POST)
    public void bindOfficeOpenIdAndMiniProgramOpenId() throws Exception {
        iWeChatMessageService.bindOfficeOpenIdAndMiniProgramOpenId();
    }


}
